#include "gofgame/jumpdown/util/HttpUtil.h"
#include <string>
using namespace gofgame::jumpdown::util;
using namespace cocos2d::extension;
using namespace cocos2d;

static HttpUtil *httpUtil = nullptr;

HttpUtil* HttpUtil::shareHttpUtil(){
	if (!httpUtil) {
		httpUtil = new HttpUtil();
	}
	return httpUtil;
}

void HttpUtil::sendPost(std::string url,CCObject *target,SEL_CallFuncND pSelector) {
	/*CCHttpRequest* request = new CCHttpRequest();
	request->setUrl("http://www.baidu.com");
	request->setRequestType(CCHttpRequest::kHttpPost);
	//request->setResponseCallback(target,pSelector);
	CCHttpClient::getInstance()->send(request);
	request->release();*/
}

void HttpUtil::sendGet(std::string url,SEL_CallFuncND pSelector) {
	CCHttpRequest* request = new CCHttpRequest();
	request->setUrl(url.c_str());
	request->setRequestType(CCHttpRequest::kHttpGet);
	request->setResponseCallback(this,pSelector);
	CCHttpClient::getInstance()->send(request);
	request->release();
}

void HttpUtil::sendPost(std::string url,std::string data,SEL_CallFuncND pSelector) {
	/*CCHttpRequest* request = new CCHttpRequest();
	request->setUrl(url.c_str());
	request->setRequestType(CCHttpRequest::kHttpPost);
	//request->setResponseCallback(this, pSelector);
	request->setRequestData(data.c_str(), strlen(data.c_str())); 
	CCHttpClient::getInstance()->send(request);
	request->release();*/
}

